<template>
	<view>
		<view class='content'>
			 <ListCard :contentList="contentList" />
		</view>
		<view class="load-more-box">
		  <uni-load-more
		    v-if="status == '请求中'"
		    status="正在加载..."
		    :showIcon="true"
		  ></uni-load-more>
		  <uni-load-more
		    v-if="status == '没有更多'"
		    status="没有更多了"
		    :showIcon="false"
		  ></uni-load-more>
		  <uni-load-more
		    v-if="status == '暂无数据'"
		    status="暂无数据"
		    :showIcon="false"
		  ></uni-load-more>
		  <uni-load-more
		    v-if="status == '请求失败'"
		    status="加载失败，点我重试"
		    :showIcon="false"
		    @click="reLoad"
		  ></uni-load-more>
		</view>
	</view>
</template>

<script>
	import ListCard from '@/components/schoolCard/card.vue'
	import config from "@/config/index.config.js";
	export default {
		components: {
		  ListCard
		},
		created() {
		},
		data() {
			return {
				contentList:[
				],
				query:{
					current: 1,
					number: 10,
					type:1
				},
				status:''
			}
		},
		onLoad() {
			this.getData()
		},
		onReachBottom() {
		  if (this.status != '没有更多') {
				if(this.type==1){
					this.getSchoolSquareList('add');
				}else{
					this.getDatasByLoc('add');
				}
			}
		},
		methods: {
			getData(type='refresh') {
				this.status = '请求中';
			if(type=='refresh'){
			  this.query={
				current: 1,
				number: 10,
				type:1
			  }
			}else{
				this.query.current++;
			}
			var that = this;
			uni.request({
				url: `${config.baseUrl}/starCityAll/circle/circleLikeQuery`,
				method: "GET",
				data: this.query,
				dataType: "json",
				header: {
					"content-type": "application/json",
					"Blade-Auth":uni.getStorageSync("token")
				},
				success: (res) => {
							for(var i in res.data.data){
								console.log(res.data.data[i])
								if(res.data.data[i].url!=null){
									res.data.data[i].url=res.data.data[i].url.split(',')
								}
								
							}
							if(type=='refresh'){
								that.contentList=[];
							}
							that.changeStatus(res.data.data)
							that.contentList=that.contentList.concat(res.data.data || []);
				}
			
			})
			},
			// 修改请求状态
			changeStatus(data) {
			  console.log(data);
			  if (this.contentList.length === 0) {
			    this.status = '暂无数据';
			  } else if (this.query.number > data.length) {
			    this.status = '没有更多';
			  } else {
			    this.status = '请求更多';
			  }
			},
		}
	}
</script>

<style lang="scss">
.top {
  top: 0;
  width: 100%;
  image {
    z-index: -1;
    width: 100%;
    position: fixed;
    top: 0;
  }
}
.navbar {
  height: 100upx;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  text {
    color: #000;
    font-weight: bolder;
  }
}
.content{
	padding:10rpx 20rpx;
	
}
.selectBtns{
	margin-top:50rpx;
	margin-left:40rpx;
	width: 300rpx;
	display: flex;
	text-align: center;
	.btn{
		margin:0 20rpx;
		flex:1;
		color:#444;
	}
	.selectedBtn{
		margin:0 10rpx;
		flex:1;
		color:#5FDB7E;
		border-bottom:8rpx solid #5FDB7E;
	}
}
</style>
